/**
 * <p>Title: Post.java</p>
 * <p>Description: DoNotes</p>
 * @author WangJun
 * @date 2009/11/15 17:20:36
 * @version 1.0
 */
package net.donotes.blog.pojo;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.TimeZone;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.google.appengine.api.datastore.Text;
import com.google.appengine.api.users.User;

/**
 * @author WangJun
 *
 */
@PersistenceCapable(identityType = IdentityType.APPLICATION, detachable="true")
public class Post {
    @PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	private Long id;
    @Persistent
	private User author;
    @Persistent
	private String slug;
    @Persistent
	private String title;
    @Persistent
	private Text content;
    @Persistent
    private String password;
    @Persistent
    private String category;
    @Persistent
	private List<String> tags;
    @Persistent
    private short type;		// 1:post(without pwd) 2:post(with pwd) 3:page
    @Persistent
    private short order;	// [post:set on top] [page:menuOrder]
    @Persistent
	private short status;	// 0:published 1:comment_able 2:comment_disable
	@Persistent
	private int visitCounter;
	@Persistent
	private int commentCounter;
    @Persistent
	private Date createDate;
    @Persistent
	private Date updateDate;
	private String createDateYYYYMMDD;
    
    /**
     * Constructors
     */
    public Post() {
    	
    }
    
    /**
     * Constructors
     * 
     * @param author
     * @param slug
     * @param title
     * @param content
     * @param password
     * @param category
     * @param tags
     * @param type
     * @param order
     * @param status
     * @param visitCounter
     * @param commentCounter
     * @param createDate
     * @param updateDate
     */
	public Post(User author, String slug, String title, Text content,
			String password, String category, List<String> tags, short type,
			short order, short status, int visitCounter, int commentCounter,
			Date createDate, Date updateDate) {
		this.author = author;
		this.slug = slug;
		this.title = title;
		this.content = content;
		this.password = password;
		this.category = category;
		this.tags = tags;
		this.type = type;
		this.order = order;
		this.status = status;
		this.visitCounter = visitCounter;
		this.commentCounter = commentCounter;
		this.createDate = createDate;
		this.updateDate = updateDate;
	}

	/**
	 * @return the id
	 */
	public Long getId() {
		return id;
	}

	/**
	 * @param id the id to set
	 */
	public void setId(Long id) {
		this.id = id;
	}

	/**
	 * @return the author
	 */
	public User getAuthor() {
		return author;
	}

	/**
	 * @param author the author to set
	 */
	public void setAuthor(User author) {
		this.author = author;
	}

	/**
	 * @return the slug
	 */
	public String getSlug() {
		return slug;
	}

	/**
	 * @param slug the slug to set
	 */
	public void setSlug(String slug) {
		this.slug = slug;
	}

	/**
	 * @return the title
	 */
	public String getTitle() {
		return title;
	}

	/**
	 * @param title the title to set
	 */
	public void setTitle(String title) {
		this.title = title;
	}

	/**
	 * @return the content
	 */
	public Text getContent() {
		return content;
	}

	/**
	 * @param content the content to set
	 */
	public void setContent(Text content) {
		this.content = content;
	}

	/**
	 * @return the password
	 */
	public String getPassword() {
		return password;
	}

	/**
	 * @param password the password to set
	 */
	public void setPassword(String password) {
		this.password = password;
	}

	/**
	 * @return the category
	 */
	public String getCategory() {
		return category;
	}

	/**
	 * @param category the category to set
	 */
	public void setCategory(String category) {
		this.category = category;
	}

	/**
	 * @return the tags
	 */
	public List<String> getTags() {
		return tags;
	}

	/**
	 * @param tags the tags to set
	 */
	public void setTags(List<String> tags) {
		this.tags = tags;
	}

	/**
	 * @return the type
	 */
	public short getType() {
		return type;
	}

	/**
	 * @param type the type to set
	 */
	public void setType(short type) {
		this.type = type;
	}

	/**
	 * @return the order
	 */
	public short getOrder() {
		return order;
	}

	/**
	 * @param order the order to set
	 */
	public void setOrder(short order) {
		this.order = order;
	}

	/**
	 * @return the status
	 */
	public short getStatus() {
		return status;
	}

	/**
	 * @param status the status to set
	 */
	public void setStatus(short status) {
		this.status = status;
	}

	/**
	 * @return the visitCounter
	 */
	public int getVisitCounter() {
		return visitCounter;
	}

	/**
	 * @param visitCounter the visitCounter to set
	 */
	public void setVisitCounter(int visitCounter) {
		this.visitCounter = visitCounter;
	}

	/**
	 * @return the commentCounter
	 */
	public int getCommentCounter() {
		return commentCounter;
	}

	/**
	 * @param commentCounter the commentCounter to set
	 */
	public void setCommentCounter(int commentCounter) {
		this.commentCounter = commentCounter;
	}

	/**
	 * @return the createDate
	 */
	public Date getCreateDate() {
		return createDate;
	}

	/**
	 * @param createDate the createDate to set
	 */
	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}

	/**
	 * @return the updateDate
	 */
	public Date getUpdateDate() {
		return updateDate;
	}

	/**
	 * @param updateDate the updateDate to set
	 */
	public void setUpdateDate(Date updateDate) {
		this.updateDate = updateDate;
	}
	
	/**
	 * @return the createDateYYYYMMDD
	 */
	public String getCreateDateYYYYMMDD() {
		SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		sdf1.setTimeZone(TimeZone.getTimeZone("GMT+8"));
		return sdf1.format(createDate);
	}
}